package com.example.leo.mycharmingstudent.a0917;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.example.leo.mycharmingstudent.R;
import com.example.leo.mycharmingstudent.a0916.HeroEntity;

import java.util.ArrayList;
import java.util.List;

public class RecyclerViewViewTypeActivity extends AppCompatActivity {

    private RecyclerView rvViewType;
    private List<HeroEntity> mHeroList/* = new ArrayList<>()*/;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycler_view_view_type);

        findViews();
        initData();
        initEvent();
    }

    private void findViews() {
        rvViewType = findViewById(R.id.rv_view_type_activity_recycler_view);
    }

    private void initData() {
        mHeroList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            if (i % 2 == 0) {
                HeroEntity entity = new HeroEntity(R.mipmap.hero3, "嫦娥" + i,
                        "神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫,神仙，住月宫");
                entity.setType(1);
                mHeroList.add(entity);
                continue;
            }
            mHeroList.add(new HeroEntity(R.mipmap.hero3, "嫦娥" + i, "神仙，住月宫"));
        }
    }

    private void initEvent() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        rvViewType.setLayoutManager(linearLayoutManager);

        rvViewType.setAdapter(new MultiViewTypeAdapter(mHeroList, this));
    }
}
